package top.zhaojx.rpc;

import top.zhaojx.rpc.config.RpcServiceConfig;
import top.zhaojx.rpc.transport.RpcClient;
import top.zhaojx.rpc.transport.RpcClientProxy;
import top.zhaojx.rpc.api.HelloObject;
import top.zhaojx.rpc.api.HelloService;
import top.zhaojx.rpc.transport.netty.client.NettyClient;

/**
 * 测试用Netty消费者
 */
public class NettyTestClient {
    public static void main(String[] args) {
        RpcClient client = new NettyClient();
        RpcServiceConfig rpcServiceConfig = new RpcServiceConfig();
        rpcServiceConfig.setGroup("test1");
        rpcServiceConfig.setVersion("version1");
        RpcClientProxy rpcClientProxy = new RpcClientProxy(client, rpcServiceConfig);
        HelloService helloService = rpcClientProxy.getProxy(HelloService.class);
        HelloObject object = new HelloObject(12, "This is a message");
        String res = helloService.hello(object);
        System.out.println(res);

        RpcServiceConfig rpcServiceConfig2 = new RpcServiceConfig();
        rpcServiceConfig2.setGroup("test2");
        rpcServiceConfig2.setVersion("version2");
        RpcClientProxy rpcClientProxy2 = new RpcClientProxy(client, rpcServiceConfig2);
        HelloService helloService2 = rpcClientProxy2.getProxy(HelloService.class);
        HelloObject object2 = new HelloObject(13, "This is other message");
        String res2 = helloService2.hello(object2);
        System.out.println(res2);
    }
}
